package com.anpy.common.service.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * <p>通用返回结果</p>
 *
 * @author sprainkle
 * @date 2019/5/2
 */
@Getter
@AllArgsConstructor
public enum ExceptionResponse implements CommonExceptionAssert {

    // 系统模块
    SUCCESS(0, "操作成功"),
    ERROR(1, "操作失败"),

    USER_NOT_EXIST(3001,"用户不存在"),

    //custom exception
    ALREADY_EXIST(30011, "数据已存在"),
    ALREADY_EXIST_REFRESH(3002, "数据已存在,刷新"),
    ALREADY_EXIST_SMS(3003, "数据已存在,需要短信验证"),
    REQUEST_UNSUCCESSFUL(4001, "请求处理失败"),
    BUSINESS_EXPIRED(4002, "业务未开通或已过期"),
    PERMISSIONS_DENIED(4003, "token校验失败"),
    NOT_FOUND(4004, "未查询到相关信息"),
    UN_SUPPORT_METHOD(4005, "请求方法错误,请核验后再试"),
    SYSTEM_EXCEPTION(5000, "系统处理错误"),
    CODE_INVALID(5001,"验证码不正确"),
    PARAMETER_VALID_ERROR(6001, "参数校验异常"),
    SERVER_BUSY(9999, "服务器繁忙"),
    ;

    /**
     * 返回码
     */
    private int code;
    /**
     * 返回消息
     */
    private String msg;

    public static void assertError(String msg){
        throw new BusinessException(ERROR.code, msg);
    }
}
